{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![Callysto Banner](https://raw.githubusercontent.com/Ariel-VB/Central-Limit-Theorem/master/Callysto_Notebook-Banner_Top_06.06.18.jpg)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "  function code_toggle() {\n",
       "    if (code_shown){\n",
       "      $('div.input').hide('500');\n",
       "      $('#toggleButton').val('Show Code')\n",
       "    } else {\n",
       "      $('div.input').show('500');\n",
       "      $('#toggleButton').val('Hide Code')\n",
       "    }\n",
       "    code_shown = !code_shown\n",
       "  }\n",
       "  \n",
       "  $( document ).ready(function(){\n",
       "    code_shown=false;\n",
       "    $('div.input').hide()\n",
       "  });\n",
       "</script>\n",
       "<form action=\"javascript:code_toggle()\"><input type=\"submit\" id=\"toggleButton\" value=\"Show Code\"></form>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Hide code\n",
    "from IPython.display import HTML\n",
    "\n",
    "HTML('''<script>\n",
    "  function code_toggle() {\n",
    "    if (code_shown){\n",
    "      $('div.input').hide('500');\n",
    "      $('#toggleButton').val('Show Code')\n",
    "    } else {\n",
    "      $('div.input').show('500');\n",
    "      $('#toggleButton').val('Hide Code')\n",
    "    }\n",
    "    code_shown = !code_shown\n",
    "  }\n",
    "  \n",
    "  $( document ).ready(function(){\n",
    "    code_shown=false;\n",
    "    $('div.input').hide()\n",
    "  });\n",
    "</script>\n",
    "<form action=\"javascript:code_toggle()\"><input type=\"submit\" id=\"toggleButton\" value=\"Show Code\"></form>''')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# An Introduction to Historical Trigonometry\n",
    "\n",
    "Hello and welcome! This set of materials is intended to accompany an introductory lesson on the history of trigonometry, developed by Kailyn Pritchard in January 2019. If you are interested in teaching such a lesson, please feel free to reach out to her at kailyn.pritchard@questu.ca for further information, and/or a copy of the lesson plan."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The following table displays the values for the six most common trigonometric functions (sine, cosine, tangent, secant, cosecant, and cotangent) when evaluated for every 15° of argument, between 0° and 90°."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Sine</th>\n",
       "      <th>Cosine</th>\n",
       "      <th>Tangent</th>\n",
       "      <th>Secant</th>\n",
       "      <th>Cosecant</th>\n",
       "      <th>Cotangent</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0°</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>Undefined</td>\n",
       "      <td>Undefined</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15°</th>\n",
       "      <td>0.258819</td>\n",
       "      <td>0.965926</td>\n",
       "      <td>0.267949</td>\n",
       "      <td>1.03528</td>\n",
       "      <td>3.8637</td>\n",
       "      <td>3.73205</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30°</th>\n",
       "      <td>0.500000</td>\n",
       "      <td>0.866025</td>\n",
       "      <td>0.57735</td>\n",
       "      <td>1.1547</td>\n",
       "      <td>2</td>\n",
       "      <td>1.73205</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45°</th>\n",
       "      <td>0.707107</td>\n",
       "      <td>0.707107</td>\n",
       "      <td>1</td>\n",
       "      <td>1.41421</td>\n",
       "      <td>1.41421</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>60°</th>\n",
       "      <td>0.866025</td>\n",
       "      <td>0.500000</td>\n",
       "      <td>1.73205</td>\n",
       "      <td>2</td>\n",
       "      <td>1.1547</td>\n",
       "      <td>0.57735</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75°</th>\n",
       "      <td>0.965926</td>\n",
       "      <td>0.258819</td>\n",
       "      <td>3.73205</td>\n",
       "      <td>3.8637</td>\n",
       "      <td>1.03528</td>\n",
       "      <td>0.267949</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>90°</th>\n",
       "      <td>1.000000</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>Undefined</td>\n",
       "      <td>Undefined</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "         Sine    Cosine    Tangent     Secant   Cosecant  Cotangent\n",
       "0°   0.000000  1.000000          0          1  Undefined  Undefined\n",
       "15°  0.258819  0.965926   0.267949    1.03528     3.8637    3.73205\n",
       "30°  0.500000  0.866025    0.57735     1.1547          2    1.73205\n",
       "45°  0.707107  0.707107          1    1.41421    1.41421          1\n",
       "60°  0.866025  0.500000    1.73205          2     1.1547    0.57735\n",
       "75°  0.965926  0.258819    3.73205     3.8637    1.03528   0.267949\n",
       "90°  1.000000  0.000000  Undefined  Undefined          1          0"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import qgrid\n",
    "import math\n",
    "\n",
    "import warnings\n",
    "warnings.filterwarnings(\"ignore\")\n",
    "\n",
    "functions = ['Sine', 'Cosine', 'Tangent', 'Secant', 'Cosecant', 'Cotangent']\n",
    "computations = [[round(math.sin(0*math.pi/180),6), round(math.cos(0*math.pi/180),6), round(math.tan(0*math.pi/180),6), round(1/(math.cos(0*math.pi/180)),6), 'Undefined', 'Undefined'], \n",
    "                 [round(math.sin(15*math.pi/180),6), round(math.cos(15*math.pi/180),6), round(math.tan(15*math.pi/180),6), round(1/(math.cos(15*math.pi/180)),6), round(1/(math.sin(15*math.pi/180)),6), round(1/(math.tan(15*math.pi/180)),6)], \n",
    "                 [round(math.sin(30*math.pi/180),6), round(math.cos(30*math.pi/180),6), round(math.tan(30*math.pi/180),6), round(1/(math.cos(30*math.pi/180)),6), round(1/(math.sin(30*math.pi/180)),6), round(1/(math.tan(30*math.pi/180)),6)],\n",
    "                 [round(math.sin(45*math.pi/180),6), round(math.cos(45*math.pi/180),6), round(math.tan(45*math.pi/180),6), round(1/(math.cos(45*math.pi/180)),6), round(1/(math.sin(45*math.pi/180)),6), round(1/(math.tan(45*math.pi/180)),6)], \n",
    "                 [round(math.sin(60*math.pi/180),6), round(math.cos(60*math.pi/180),6), round(math.tan(60*math.pi/180),6), round(1/(math.cos(60*math.pi/180)),6), round(1/(math.sin(60*math.pi/180)),6), round(1/(math.tan(60*math.pi/180)),6)], \n",
    "                 [round(math.sin(75*math.pi/180),6), round(math.cos(75*math.pi/180),6), round(math.tan(75*math.pi/180),6), round(1/(math.cos(75*math.pi/180)),6), round(1/(math.sin(75*math.pi/180)),6), round(1/(math.tan(75*math.pi/180)),6)],\n",
    "                 [round(math.sin(90*math.pi/180),6), round(math.cos(90*math.pi/180),6), 'Undefined', 'Undefined', round(1/(math.sin(90*math.pi/180)),6), round(1/(math.tan(90*math.pi/180)),6)]] \n",
    "arguments = [\"0°\" , \"15°\", \"30°\", \"45°\", \"60°\", \"75°\", \"90°\"]\n",
    "\n",
    "trigTable = pd.DataFrame(data = computations, columns = functions , index = arguments)\n",
    "\n",
    "display(trigTable)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As we discussed in class, historical astronomers did not have access to decimal fractional notation, so instead of using the unit circle, they used circles with radii much larger than 1. We can now choose our own radius, and have the computer program calculate the table for us!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "What radius would you like to use? 60000\n"
     ]
    }
   ],
   "source": [
    "rad = input(\"What radius would you like to use? \")\n",
    "Rad = int(rad)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Below, we can now see the same table, computed for a circle of radius 60000.\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Sine</th>\n",
       "      <th>Cosine</th>\n",
       "      <th>Tangent</th>\n",
       "      <th>Secant</th>\n",
       "      <th>Cosecant</th>\n",
       "      <th>Cotangent</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0°</th>\n",
       "      <td>0.0</td>\n",
       "      <td>60000.0</td>\n",
       "      <td>0</td>\n",
       "      <td>60000</td>\n",
       "      <td>Undefined</td>\n",
       "      <td>Undefined</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15°</th>\n",
       "      <td>15529.0</td>\n",
       "      <td>57956.0</td>\n",
       "      <td>16077</td>\n",
       "      <td>62117</td>\n",
       "      <td>231822</td>\n",
       "      <td>223923</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30°</th>\n",
       "      <td>30000.0</td>\n",
       "      <td>51962.0</td>\n",
       "      <td>34641</td>\n",
       "      <td>69282</td>\n",
       "      <td>120000</td>\n",
       "      <td>103923</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>45°</th>\n",
       "      <td>42426.0</td>\n",
       "      <td>42426.0</td>\n",
       "      <td>60000</td>\n",
       "      <td>84853</td>\n",
       "      <td>84853</td>\n",
       "      <td>60000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>60°</th>\n",
       "      <td>51962.0</td>\n",
       "      <td>30000.0</td>\n",
       "      <td>103923</td>\n",
       "      <td>120000</td>\n",
       "      <td>69282</td>\n",
       "      <td>34641</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75°</th>\n",
       "      <td>57956.0</td>\n",
       "      <td>15529.0</td>\n",
       "      <td>223923</td>\n",
       "      <td>231822</td>\n",
       "      <td>62117</td>\n",
       "      <td>16077</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>90°</th>\n",
       "      <td>60000.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>Undefined</td>\n",
       "      <td>Undefined</td>\n",
       "      <td>60000</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        Sine   Cosine    Tangent     Secant   Cosecant  Cotangent\n",
       "0°       0.0  60000.0          0      60000  Undefined  Undefined\n",
       "15°  15529.0  57956.0      16077      62117     231822     223923\n",
       "30°  30000.0  51962.0      34641      69282     120000     103923\n",
       "45°  42426.0  42426.0      60000      84853      84853      60000\n",
       "60°  51962.0  30000.0     103923     120000      69282      34641\n",
       "75°  57956.0  15529.0     223923     231822      62117      16077\n",
       "90°  60000.0      0.0  Undefined  Undefined      60000          0"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "print('Below, we can now see the same table, computed for a circle of radius ' + str(Rad) + '.')\n",
    "\n",
    "functions2 = ['Sine', 'Cosine', 'Tangent', 'Secant', 'Cosecant', 'Cotangent']\n",
    "\n",
    "computations2 = [[round(Rad*trigTable.loc['0°', 'Sine'],0), round(Rad*trigTable.loc['0°', 'Cosine'],0), round(Rad*trigTable.loc['0°', 'Tangent'],0), round(Rad*trigTable.loc['0°', 'Secant'],0), 'Undefined', 'Undefined'], \n",
    "                 [round(Rad*trigTable.loc['15°', 'Sine'],0), round(Rad*trigTable.loc['15°', 'Cosine'],0), round(Rad*trigTable.loc['15°', 'Tangent'],0), round(Rad*trigTable.loc['15°', 'Secant'],0), round(Rad*trigTable.loc['15°', 'Cosecant'],0), round(Rad*trigTable.loc['15°', 'Cotangent'],0)], \n",
    "                 [round(Rad*trigTable.loc['30°', 'Sine'],0), round(Rad*trigTable.loc['30°', 'Cosine'],0), round(Rad*trigTable.loc['30°', 'Tangent'],0), round(Rad*trigTable.loc['30°', 'Secant'],0), round(Rad*trigTable.loc['30°', 'Cosecant'],0), round(Rad*trigTable.loc['30°', 'Cotangent'],0)],\n",
    "                 [round(Rad*trigTable.loc['45°', 'Sine'],0), round(Rad*trigTable.loc['45°', 'Cosine'],0), round(Rad*trigTable.loc['45°', 'Tangent'],0), round(Rad*trigTable.loc['45°', 'Secant'],0), round(Rad*trigTable.loc['45°', 'Cosecant'],0), round(Rad*trigTable.loc['45°', 'Cotangent'],0)], \n",
    "                 [round(Rad*trigTable.loc['60°', 'Sine'],0), round(Rad*trigTable.loc['60°', 'Cosine'],0), round(Rad*trigTable.loc['60°', 'Tangent'],0), round(Rad*trigTable.loc['60°', 'Secant'],0), round(Rad*trigTable.loc['60°', 'Cosecant'],0), round(Rad*trigTable.loc['60°', 'Cotangent'],0)], \n",
    "                 [round(Rad*trigTable.loc['75°', 'Sine'],0), round(Rad*trigTable.loc['75°', 'Cosine'],0), round(Rad*trigTable.loc['75°', 'Tangent'],0), round(Rad*trigTable.loc['75°', 'Secant'],0), round(Rad*trigTable.loc['75°', 'Cosecant'],0), round(Rad*trigTable.loc['75°', 'Cotangent'],0)],\n",
    "                 [round(Rad*trigTable.loc['90°', 'Sine'],0), round(Rad*trigTable.loc['90°', 'Cosine'],0), 'Undefined', 'Undefined', round(Rad*trigTable.loc['90°', 'Cosecant'],0), round(Rad*trigTable.loc['90°', 'Cotangent'],0)]]\n",
    "\n",
    "arguments2 = [\"0°\" , \"15°\", \"30°\", \"45°\", \"60°\", \"75°\", \"90°\"]\n",
    "\n",
    "trigTable2 = pd.DataFrame(data = computations2, columns = functions2 , index = arguments2)\n",
    "\n",
    "display(trigTable2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "![Callysto Banner](https://github.com/Ariel-VB/Central-Limit-Theorem/blob/master/Callysto_Notebook-Banners_Bottom_06.06.18.jpg?raw=true)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
